#ifndef _DOFCATMULLROMSPLINE_
#define _DOFCATMULLROMSPLINE_

#include "DofAbstract.h"
#include "SplineCatmullRom.h"
#include <cassert>

class DofSplineCatmullRom:public DofAbstract{
	private:
		SplineCatmullRom *mSplineCR;
		int mFrameOffset;

	public:
		DofSplineCatmullRom(int _index);
		DofSplineCatmullRom(int _index, vector<Vec2d> _ctrlPts);
		DofSplineCatmullRom(int _index, double nfstart, double nfend, int npts);

		double getValue(double _frame);
		double getSlope(double _frame);
		double getSecondSlope(double _frame);

		double getCtrlPtCoord(int _numC);
		double getCtrlPtValue(int _numC);
		void setCtrlPtValue(int _numC, double _v);

		vector<Vec2d> getCtrlPts();
		void getCtrlPts(double *state);
		void getCtrlPts(double *state, int _start, int _end);
		void setCtrlPts(double *state);
		void setCtrlPts(double *state, int _start, int _end);
		void addCtrlPtsDiff(double *state, int _start, int _end);

		void setValue(double nFrame, double val);
		void initValues(vector<double> q);

		double getDerivative(double nFrame, int npt);	// derivative wrt to ith ctrlpt
		double getSlopeDerivative(double nFrame, int npt);	// derivative of vel wrt to ith ctrlpt
		double getSecondDerivative(double nFrame, int npt);

		void getCtrlPtIndices(double nFrame, int *npts, vector<int> *indices);
		void getVelCtrlPtIndices(double nFrame, int *npts, vector<int> *indices);

		void scaleTime(double _s){mSplineCR->scaleTime(_s);}
		void scaleIntervalTime(double _fs, double _fe, double _scale){mSplineCR->scaleIntervalTime(_fs, _fe, _scale);}
		void setOffsetTime(double _o){mSplineCR->setOffsetTime(_o);}
		// resample with specified spacing
		void reSample(double _numPts);

		void addConstant(double _c);
};

#endif
